home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / PickMeUp.sit / Pick Me Up / source code / Movie app source / pickmeUp97 / source / PP Basic Starter.cp < prev    next >
Text File  |  1997-06-27  |  5KB  |  194 lines

  1. // ===========================================================================
  2. //    PP Basic Starter.cp         ©1994-1997 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a basic PowerPlant application
  6.  
  7. #include "PP Basic Starter.h"
  8.  
  9. #include <LGroupBox.h>
  10.  
  11. #include <LGrowZone.h>
  12. #include <LWindow.h>
  13. #include <PP_Messages.h>
  14. #include <PP_Resources.h>
  15. #include <PPobClasses.h>
  16. #include <UDrawingState.h>
  17. #include <UMemoryMgr.h>
  18. #include <URegistrar.h>
  19. #include <LEditField.h>
  20. #include "CMoviePane.h"
  21. #include "CMovieWind.h"
  22.  
  23. // put declarations for resource ids (ResIDTs) here
  24.  
  25. const ResIDT    window_Sample        = 1;    // EXAMPLE
  26.  
  27.  
  28. // ===========================================================================
  29. //        • Main Program
  30. // ===========================================================================
  31.  
  32. void main(void)
  33. {
  34.                                     // Set Debugging options
  35.     SetDebugThrow_(debugAction_LowLevelDebugger);
  36.     SetDebugSignal_(debugAction_LowLevelDebugger);
  37.  
  38.     InitializeHeap(3);                // Initialize Memory Manager
  39.                                     // Parameter is number of Master Pointer
  40.                                     //   blocks to allocate
  41.     
  42.                                     // Initialize standard Toolbox managers
  43.     UQDGlobals::InitializeToolbox(&qd);
  44.     
  45.     new LGrowZone(20000);            // Install a GrowZone function to catch
  46.                                     //    low memory situations.
  47.  
  48.     CPPStarterApp    theApp;            // replace this with your App type
  49.     theApp.Run();
  50. }
  51.  
  52.  
  53. // ---------------------------------------------------------------------------
  54. //        • CPPStarterApp             // replace this with your App type
  55. // ---------------------------------------------------------------------------
  56. //    Constructor
  57.  
  58. CPPStarterApp::CPPStarterApp()
  59. {
  60.     // Register functions to create core PowerPlant classes
  61.     
  62.     RegisterAllPPClasses();
  63.     RegisterClass_(CMoviePane);
  64.     RegisterClass_(CMovieWind);
  65.     RegisterClass_(LGroupBox);
  66.     mWindow = nil;
  67.     mFirstTime = true;
  68. }
  69.  
  70.  
  71. // ---------------------------------------------------------------------------
  72. //        • ~CPPStarterApp            // replace this with your App type
  73. // ---------------------------------------------------------------------------
  74. //    Destructor
  75. //
  76.  
  77. CPPStarterApp::~CPPStarterApp()
  78. {
  79. }
  80.  
  81. // ---------------------------------------------------------------------------
  82. //        • StartUp
  83. // ---------------------------------------------------------------------------
  84. //    This function lets you do something when the application starts up
  85. //    without a document. For example, you could issue your own new command.
  86.  
  87. void
  88. CPPStarterApp::StartUp()
  89. {
  90.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  91. }
  92.  
  93. // ---------------------------------------------------------------------------
  94. //        • ObeyCommand
  95. // ---------------------------------------------------------------------------
  96. //    Respond to commands
  97.  
  98. Boolean
  99. CPPStarterApp::ObeyCommand(
  100.     CommandT    inCommand,
  101.     void        *ioParam)
  102. {
  103.     Boolean        cmdHandled = true;
  104.  
  105.     switch (inCommand) {
  106.     
  107.         // Deal with command messages (defined in PP_Messages.h).
  108.         // Any that you don't handle will be passed to LApplication
  109.              
  110.         case cmd_New:
  111.             //Debugger();
  112.             mWindow = (CMovieWind*)LWindow::CreateWindow(100, this);
  113.             Assert_(mWindow);
  114.             mWindow->Show();
  115.             //mWindow->Play();
  116.         break;
  117.  
  118.  
  119.  
  120.         default:
  121.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  122.             break;
  123.     }
  124.     
  125.     return cmdHandled;
  126. }
  127.  
  128. // ---------------------------------------------------------------------------
  129. //        • FindCommandStatus
  130. // ---------------------------------------------------------------------------
  131. //    This function enables menu commands.
  132. //
  133.  
  134. void
  135. CPPStarterApp::FindCommandStatus(
  136.     CommandT    inCommand,
  137.     Boolean        &outEnabled,
  138.     Boolean        &outUsesMark,
  139.     Char16        &outMark,
  140.     Str255        outName)
  141. {
  142.  
  143.     switch (inCommand) {
  144.     
  145.         // Return menu item status according to command messages.
  146.         // Any that you don't handle will be passed to LApplication
  147.  
  148.         case cmd_New:                    // EXAMPLE
  149.             outEnabled = true;            // enable the New command
  150.             break;
  151.  
  152.         default:
  153.             LApplication::FindCommandStatus(inCommand, outEnabled,
  154.                                                 outUsesMark, outMark, outName);
  155.             break;
  156.     }
  157. }
  158.  
  159.  
  160. // ---------------------------------------------------------------------------
  161. //        • EventResume
  162. // ---------------------------------------------------------------------------
  163. //    
  164. //
  165. void
  166. CPPStarterApp::EventResume(const EventRecord&  inMacEvent)
  167. {
  168.     inherited::EventResume(inMacEvent);
  169.     mWindow->Show();
  170.     //mWindow->Play();
  171.     
  172. }
  173.  
  174.  
  175. // ---------------------------------------------------------------------------
  176. //        • EventActivate
  177. // ---------------------------------------------------------------------------
  178. //    
  179. //
  180. void
  181. CPPStarterApp::EventActivate(const EventRecord&  inMacEvent)
  182. {
  183.     inherited::EventActivate(inMacEvent);
  184.     //mWindow->Show();
  185.     mWindow->Play();
  186.     /*
  187.     if(!mFirstTime)
  188.     {
  189.         mWindow->Play();
  190.     }else{
  191.             mFirstTime = false;
  192.         }
  193.     */
  194. }